package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.pipe.domain.TransformMedia;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 传输介质信息表
 */
public class TransformMediaVO extends BaseVO<TransformMedia> {

    // 管道名称
    private String pipeLineName;
    // 介质类型
    private String mediaType;
    // 温度（℃）
    private BigDecimal temperature;
    // PH
    private BigDecimal ph;
    // 二氧化碳含量(%)
    private BigDecimal co2;
    // 氯含量(%)
    private BigDecimal cl;
    // 密度
    private BigDecimal density;
    // 硫化氢含量(%)
    private BigDecimal h2s;
    // 水含量(%)
    private BigDecimal h2o;
    // 沸点(℃)
    private BigDecimal boil;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getMediaType() {
        return mediaType;
    }

    public void setMediaType(String mediaType) {
        this.mediaType = mediaType;
    }

    public BigDecimal getTemperature() {
        return temperature;
    }

    public void setTemperature(BigDecimal temperature) {
        this.temperature = temperature;
    }

    public BigDecimal getPh() {
        return ph;
    }

    public void setPh(BigDecimal ph) {
        this.ph = ph;
    }

    public BigDecimal getCo2() {
        return co2;
    }

    public void setCo2(BigDecimal co2) {
        this.co2 = co2;
    }

    public BigDecimal getCl() {
        return cl;
    }

    public void setCl(BigDecimal cl) {
        this.cl = cl;
    }

    public BigDecimal getDensity() {
        return density;
    }

    public void setDensity(BigDecimal density) {
        this.density = density;
    }

    public BigDecimal getH2s() {
        return h2s;
    }

    public void setH2s(BigDecimal h2s) {
        this.h2s = h2s;
    }

    public BigDecimal getH2o() {
        return h2o;
    }

    public void setH2o(BigDecimal h2o) {
        this.h2o = h2o;
    }

    public BigDecimal getBoil() {
        return boil;
    }

    public void setBoil(BigDecimal boil) {
        this.boil = boil;
    }

    public void fromDomain(TransformMedia domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 介质类型
        this.mediaType = CodeUtil.getName(domain.getMediaType());
        // 温度（℃）
        this.temperature = domain.getTemperature();
        // PH
        this.ph = domain.getPh();
        // 二氧化碳含量(%)
        this.co2 = domain.getCo2();
        // 氯含量(%)
        this.cl = domain.getCl();
        // 密度
        this.density = domain.getDensity();
        // 硫化氢含量(%)
        this.h2s = domain.getH2s();
        // 水含量(%)
        this.h2o = domain.getH2o();
        // 沸点(℃)
        this.boil = domain.getBoil();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<TransformMediaVO> fromDomainList(Page<TransformMedia> domainList) {
        Page<TransformMediaVO> list = new Page<TransformMediaVO>();
        for (TransformMedia transformMedia : domainList) {
            TransformMediaVO transformMediaVO = new TransformMediaVO();
            transformMediaVO.fromDomain(transformMedia);
            list.add(transformMediaVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}